<?php
/**
 * 后台登陆视图
 */
class LoginAction extends Action {
	/**
	 * 后台登陆页面
	 * @return [type] [description]
	 */
    public function index(){
        $this->display();
    }

    /**
     * 登入口
     * @return [type] [description]
     */
    public function login(){
        $this->display();    
    }

    /**
     * 检测用户
     * @return [type] [description]
     */
    public function checkUser(){
    	if($this->isAjax()){
            $userName = $this->_post('username');
            $userPwd = $this->_post('password');
            $userName = cleanInput($userName);
    		$db = M("qwe");
            $result = $db->field('uid,username,password')->where(array('username'=>$userName))->find();
            $info = array();
            if(is_array($result) && count($result)>1){
                if($result['password'] == md5($userPwd)){
                    $info = array('status'=>'ok','msg'=>'登录成功！');
                    $_SESSION['uid'] = $result['uid'];
                    $_SESSION['username'] = $result['username'];
                }else{
                    $info = array('status'=>'error','msg'=>'您输入的密码有误，请重新输入！');
                }                
            }else{
                $info = array('status'=>'error','msg'=>'该管理员账号不存在！');
            }
            echo json_encode($info);
            exit();
    	}else{
            die('what are you want to do?');
        }
    }


}
?>